package com.wenwenli.boot.beans;

public class FactoryBean {

    public static <T> T getBean(Class<T> clazz) {
        try {
            if (clazz.isInterface()) {
                throw new RuntimeException(clazz.getName() + "is interface can not instance ");
            } else {
                return clazz.newInstance();
            }
        } catch (InstantiationException e) {
            throw new RuntimeException(clazz.getName() + "is a abstract class can not instance ");
        } catch (IllegalAccessException e) {
            throw new RuntimeException(clazz.getName() + " please confirm the constructor is accessible ");
        }
    }
}
